package com.atguigu.excel;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author lxx
 * @version 1.0
 * @since 2022/6/30 13:46
 */
public class ExcelListener extends AnalysisEventListener<User> {
    // 创建list集合封装最终的数据
    List<User> list = new ArrayList<>();

    // 一行一行去读取excle内容
    @Override
    public void invoke(User user, AnalysisContext analysisContext) {
        list.add(user);
    }

    // 读取excel表头信息
    @Override
    public void invokeHeadMap(Map<Integer, String> headMap, AnalysisContext context) {
        System.out.println("表头信息：" + headMap);
    }

    // 读取完成后执行
    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {
        System.out.println("读取结束...");
    }
}
